home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 255_01 / gpclip1.asm < prev    next >
Encoding:
Assembly Source File  |  1988-03-28  |  2.5 KB  |  79 lines

  1.           page   80,132
  2.           page
  3. ;
  4. ;         Kent Cedola
  5. ;         2015 Meadow Lake Court
  6. ;         Norfolk, Virginia  23518
  7. ;
  8.  
  9. dgroup    group  _data
  10.  
  11. _data     segment word public 'data'
  12.           assume ds:dgroup
  13.  
  14.           extrn  _gdwd_x1:word,_gdwd_x2:word,_gdwd_x3:word
  15.           extrn  _gdwd_y1:word,_gdwd_y2:word,_gdwd_y3:word
  16.           extrn  _gdvw_x1:word,_gdvw_x2:word,_gdvw_x3:word
  17.           extrn  _gdvw_y1:word,_gdvw_y2:word,_gdvw_y3:word
  18.           extrn  _gdc_flg:byte
  19.  
  20. _data     ends
  21.  
  22. _text     segment byte public 'code'
  23.  
  24.           assume cs:_text,ds:dgroup
  25.           public _gpclip1
  26. _gpclip1  proc   near
  27.  
  28.           push   bp
  29.           mov    bp,sp
  30.  
  31.           push   si
  32.           push   di
  33.  
  34.           mov    si,[bp+4]
  35.           mov    di,[bp+6]
  36.  
  37.           mov    cx,[si]
  38.           mov    bx,[di]
  39.  
  40.           cmp    cx,_gdwd_x1           ; If the scale (real) X,Y coordinates
  41.           jb     outside               ;   ... are not in the current viewport
  42.           cmp    cx,_gdwd_x2           ;   ... and the clipping mode is on
  43.           ja     outside               ;   ... ignore this plot
  44.           cmp    bx,_gdwd_y1           ;   ...
  45.           jb     outside               ;   ...
  46.           cmp    bx,_gdwd_y2           ;   ...
  47.           ja     outside               ;   ...
  48.  
  49.           MOV    AX,CX                 ; Copy X coordinate to a work register
  50.           SUB    AX,_gdwd_x1           ; Substract the Window's X offset
  51.           MUL    _gdvw_x3              ; Multiply by the Viewport's X delta
  52.           DIV    _gdwd_x3              ; Divide by the Window's X offset
  53.           ADD    AX,_gdvw_x1           ; Add the Viewport's X offset
  54.           MOV    [si],AX               ; Copy the converted X back to CX
  55.  
  56.           MOV    AX,BX                 ; Copy Y coordinate to a work register
  57.           SUB    AX,_gdwd_y1           ; Substract the Window's Y offset
  58.           MUL    _gdvw_y3              ; Multiply by the Viewport's Y delta
  59.           DIV    _gdwd_y3              ; Divide by the Window's Y offset
  60.           ADD    AX,_gdvw_y1           ; Add the Viewport's Y offset
  61.           MOV    [di],AX               ; Copy the converted Y back to CX
  62.           xor    al,al
  63.           jmp    short done            ;
  64. outside:
  65.           mov    al,-1
  66. done:
  67.           mov    _gdc_flg,al
  68.           xor    ah,ah
  69.  
  70.           pop    di
  71.           pop    si
  72.  
  73.           pop    bp
  74.           ret
  75. _gpclip1  endp
  76.  
  77. _text     ends
  78.           end
  79.